package com.mutual.reins.config.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mutual.reins.config.entity.FhPriority;
import com.mutual.reins.config.mapper.FhPriorityMapper;
import com.mutual.reins.config.service.IFhPriorityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author CodeGenerate
 * @since 2021-04-27
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class FhPriorityServiceImpl extends ServiceImpl<FhPriorityMapper, FhPriority> implements IFhPriorityService {

    @Autowired
    private FhPriorityMapper fhPriorityMapper;
    /**
     * 查询FhPriority表count数量
     *
     * @param uwYear 业务起保年度
     * @return count=0:true   count<>false
     */
    @Override
    public boolean ifTreatyValid(String uwYear) {
        QueryWrapper<FhPriority> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("UwYear",uwYear);
        int count = this.count(queryWrapper);
        if(count == 0){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 根据业务年度、业务起保日期查询合约优先级配置表
     *
     * @param uwYear    业务年度
     * @param startDate 业务起保日期
     * @return 合约优先级配置表
     */
    @Override
    public List<FhPriority> selectUwYearInFhTreaty(String uwYear, String startDate) {
        return fhPriorityMapper.selectUwYearInFhTreaty(uwYear,startDate);
    }
}
